package com.demo.jpa.dao.repository;

import com.demo.jpa.dao.entity.UserEntity;
import com.demo.jpa.exten.OnlyName;
import com.demo.jpa.exten.OnlyNameBySpel;
import com.demo.jpa.exten.OnlyNameBySimpleSpel;
import com.demo.jpa.exten.OnlyNameBySpelPrefix;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.scheduling.annotation.Async;
import org.springframework.util.concurrent.ListenableFuture;

import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
import java.util.stream.Stream;

/**
 * @Author:liaoyoule
 * @Description
 * @Date: Created in 15:55 2018/7/20
 * @Modifyied By:
 */
public interface UserRepository extends JpaRepository<UserEntity, Integer> {
    Stream<UserEntity> findByUidIn(List<Integer> inIds);

    @Async
    CompletableFuture<UserEntity> findOneByUid(int uid);

    @Async
    Future<UserEntity> findByUid(int i);

    @Async
    ListenableFuture<UserEntity> queryByUid(int i);

    Stream<OnlyName> findByUidNotNull();

    Stream<OnlyNameBySimpleSpel> queryByUidNotNull();

    Stream<OnlyNameBySpel> findOneByUidNotNull();

    Stream<OnlyNameBySpelPrefix> findTop3ByUidNotNull();

    Stream<UserEntity> findByPassword();


    Stream<String> findAllByNativeQuery();


}
